#include<bits/stdc++.h>
using namespace std;
int n,maxa=-1,l=1,ans=0;
int r[100000+10],a[100000+10];
struct ma{
    int num,zhi;
};
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>r[i];
        maxa=max(maxa,r[i]);
        a[r[i]]++;
    }
    
    bool fl=1;
    ma t,s;
    while(l<=maxa){
        while(a[l]==0)l++;
        if(fl){
            s.num=l;
            s.zhi=a[l];
            fl=0;
        }
        else{
            t.num=l;
            t.zhi=a[l];
            cout<<t.num<<" "<<t.zhi<<endl;
        
            cout<<s.num<<" "<<s.zhi<<endl<<endl;
            ans+=min(s.zhi,t.zhi);
            s.zhi=max(s.zhi,t.zhi);
            s.num=t.num;
        }
        
        l++;
    }
    cout<<n-ans;
    return 0;
}